from fastapi import APIRouter, Request,Response
from fastapi.templating import Jinja2Templates
#重定向
from starlette.responses import RedirectResponse
import os,sys
index_router = APIRouter()
BASE_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
path = os.path.join(BASE_DIR, 'app/templates')
templates = Jinja2Templates(directory=path)


@index_router.get("/")
def get_index(request:Request):
    return templates.TemplateResponse("index.html", {"request": request})
    # return RedirectResponse('/login')